package JAVA300.第九章容器;

import java.util.*;

/**
 * 使用容器存储表格数据
 * ORM思想的简单实验2： javabean表示一行数据，整张表存在list/map中
 */
public class TestStoreTableData01 {
    public static void main(String[] args) {

     User user1 = new User(01,"hqq",10001);
     User user2 = new User(02,"qyh",1000);

     //list
//     List<User> list = new ArrayList<>();
//     list.add(user1);
//     list.add(user2);
//
//     for (User user:list){
//         System.out.println(user);
//     }

     //map
        Map<Integer,User> map = new HashMap<>();
        map.put(user1.getId(),user1);
        map.put(user2.getId(),user2);


        Set<Integer> keySet = map.keySet();
        for (Integer key:keySet){
            System.out.println(key+"===="+map.get(key));
        }
    }
}

class User{
    private int id;
    private String name;
    private double salary;

    //
    public User() {
    }

    public User(int id, String name, double salary) {
        this.id = id;
        this.name = name;
        this.salary = salary;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", salary=" + salary +
                '}';
    }
}
